#ifndef CONSTRAINTS_H_
#define CONSTRAINTS_H_
#include "Value.h"

class MinMaxConstraint:  public Listener {
	
private:
	long min,max;
	
public:
	~MinMaxConstraint() {}
	MinMaxConstraint(long _min,long _max) {
		min=_min;
		max = _max;
		acceptedValues = INT|DOUBLE|FLOAT|LONG;
	}
	short intChanged(long _id,unsigned int _index,Value<int> *c) {
		printf("intChanged: %d\n",c->getValue());
		return c->getValue()>min && c->getValue()<max;
	}
	short floatChanged(long _id,unsigned int _index,Value<float> *c) {
			printf("floatChanged: %f\n",c->getValue());
			return c->getValue()>min && c->getValue()<max;
		}
	short doubleChanged(long _id,unsigned int _index,Value<double> *c) {
			printf("doubleChanged: %f\n",c->getValue());
			return c->getValue()>min && c->getValue()<max;
		}
	short longChanged(long _id,unsigned int _index,Value<long> *c) {
			
			return c->getValue()>min && c->getValue()<max;
		}
	
	
};
template <typename type>
class Connector : public Listener {
private:
	Prop<type> *prop;
public: 
	Connector(Prop<type> *_prop) {
		prop = _prop;
	}
	~Connector() {}
	
	short int valueChanged(long _id,unsigned int _index,ValueContainer *c){
		
		Value<type> *v = (Value<type>*)c->getPointer();
		prop->set(v->getValue());
		return true; 
	}
};



#endif /*CONSTRAINTS_H_*/
